// components/TabBar/TabBar.js
import {storeBindingsBehavior} from 'mobx-miniprogram-bindings'
import {store} from "../../store/sotre"

Component({
  behaviors:[storeBindingsBehavior],
  storeBindings:{
      //数据源
      store,
      fields:{
          active: 'active',
          checkNum: 'checkNum',
          icon: 'icon'
      },
      actions:{
        updataActive:'updataActive'
      }
  },
  /**
   * 组件的属性列表
   */
  properties: {

  },

  /**
   * 组件的初始数据
   */
  data: {
    "list": [{
      "pagePath": "/pages/home/home",
      "text": "首页"
    },{
      "pagePath": "/pages/list/list",
      "text": "商城"
    },{
      "pagePath": "/pages/like/like",
      "text": "购物",
      "isCart" : true,
    },{
      "pagePath": "/pages/user/user",
      "text": "我的"
    }]
  },
  /**
   * 组件的方法列表
   */
  methods: {
    // 切换标签页
    onChange(event) {
      this.updataActive(event.detail)
      wx.switchTab({
        url: this.data.list[event.detail].pagePath,
      })
    },
  }
})